function BYID(id){
	 return document.getElementById(id);
}
  /**
  *pageNo 当前第几页
  totalPage 总页数
  objInnerHtml 显示分页标签的对象
  url  ajax分页链接
  dataInnerHtml 分页数据显示的对象
  obj 分页对象的名称
  objPageNO 显示当前第几也对象
  **/
  function pagination(pageNo,totalPage,objInnerHtml,url,dataInnerHtml,obj,objPageNO,isAjax){
   this.pageNo=pageNo;
   this.totalPage=totalPage;
   this.objInnerHtml=objInnerHtml;
   this.startPageNo=3; //往前显示页
   this.endPageNo=5; //从开始也往后条数
   this.url=url;
   this.dataInnerHtml=dataInnerHtml;
   this.obj=obj;
   this.objPageNO=objPageNO;
   this.isAjax=isAjax;
   this.init();
  }
  pagination.prototype.maintenanceHasSentPageNo=function(){
   this.objPageNO.innerHTML=this.pageNo;
  }
  //下一页
  pagination.prototype.next=function(){
	  this.pageNo++;
	  this.go(this.pageNo);
  }
  
  //上一页
  pagination.prototype.on=function(){
      this.pageNo--;
      this.go(this.pageNo);
  }

  //到第几页
  pagination.prototype.go=function(pageNo){
    this.pageNo=pageNo;
    if(this.maintenance()){
    	if(this.isAjax==true){
	        this.doAjaxPage(this.pageNo,this.dataInnerHtml);
	        this.init();
	        this.maintenanceHasSentPageNo();
    	}
    	else{
    		BYID("hiddenPageNO").value=this.pageNo;
    		BYID("form").submit();
    	}
	}
    
  }
  
  pagination.prototype.maintenance=function(){
	  if(this.pageNo<1){
		   this.pageNo=1;
		return false;
      }else if(this.pageNo>this.totalPage){
    	  this.pageNo=this.totalPage;
  		  return false;
      }
	  return true;
  }

  pagination.prototype.doAjaxPage=function(N,D){
  												KISSY.io({
	                                        		type: 'POST',
	                                        		async: false,
	                                        		url: this.url,
	                                        		data: {"pageNo":N},
	                                        		success: function(data, textStatus, xhr) {
	                                        			D.innerHTML=data;
	                                        		}
	                                        		,error:function(){
		                                        		alert("request is error");}
	                                        	});
  }
  pagination.prototype.init=function(){
    var start=this.pageNo-this.startPageNo;//从那一条开始循环
	if(start<1)
	  start=1;
	var end=start+this.endPageNo;//计算结束循环的条数
	if(end>this.totalPage)
	 end=this.totalPage;

     var html="<div class='pagination'>";
         html+="<div class='page-position'>";
         html+="<a class='page-pre' href='javascript:"+this.obj+".on()'>上一页</a>" 
	 //开始初始化 分页页码
	 for(var i=start;i<=end;i++){
	   if(i==this.pageNo){
	   	html+="<a  class='page-cur' href='javascript:"+this.obj+".go("+i+")'>"+i+"</a>";
	   }else{
	    html+="<a  href='javascript:"+this.obj+".go("+i+")'>"+i+"</a>";
	   }
	 }
         html+="<a class='page-next' href='javascript:"+this.obj+".next()'>下一页</a>";
       
      html+="</div>";
      html+="</div>";
      this.objInnerHtml.innerHTML=html;
  }